<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/4/30
 * Time: 11:33
 */
namespace app\doctor\controller;

use app\common\model\Base;

class Doctorinfo extends Base{

    public function index(){
        $this->selectAllInfo();
    }

    function selectAllInfo() {
        $sql = "SELECT * FROM doctor_doctor";
        $result = $this->mysql->selectSQLAll($sql);
        if (is_array($result)) {
            $this->getAllInfo($result);
        } else {
            echo echoJson(0, "暂无记录!");
        }
    }

    function getAllInfo($result) {
        $Info = array();
        foreach ($result as $row) {
            $name = isset($row["name"]) ? $row["name"] : null;
            $speciality = isset($row["speciality"]) ? $row["speciality"] : null;
            $position = isset($row["position"]) ? $row["position"] : null;
            $doctor_head_portrait = isset($row["doctor_head_portrait"]) ? $row["doctor_head_portrait"] : null;
            $detail_position = isset($row["detail_position"]) ? $row["detail_position"] : null;
            $birth = isset($row["birth"]) ? $row["birth"] : null;
            $birthplace = isset($row["birthplace"]) ? $row["birthplace"] : null;
            $nationality = isset($row["nationality"]) ? $row["nationality"] : null;
            $sex = isset($row["sex"]) ? $row["sex"] : null;
            $nation = isset($row["nation"]) ? $row["nation"] : null;
            $intro = isset($row["intro"]) ? $row["intro"] : null;
            $study_experience = isset($row["study_experience"]) ? json_decode($row["study_experience"], true) : $null;
            $work_experience = isset($row["work_experience"]) ? json_decode($row["work_experience"], true) : null;
            $Info[] = array("name" => $name, "speciality" => $speciality, "position" => $position, "doctor_head_portrait" => $doctor_head_portrait, "detail_position" => $detail_position,
                "birth" => $birth, "birthplace" => $birthplace, "nationality" => $nationality, "sex" => $sex, "nation" => $nation,
                "nationality" => $nationality, "intro" => $intro, "study_experience" => $study_experience, "work_experience" => $work_experience);
        }
        $explain = "中医药学，博大精深，源远流长，是祖国文化宝藏中一颗璀璨的明珠，为中华民族的繁衍昌盛作出了巨大贡献。清史记载：“江南医学最盛”，明清以降，吴中医学、孟河学派执耳江苏杏林。新中国成立后，御医后人，岐黄世家，荟萃南京，一代大师开创江苏省中医院学术之先河，为这所建国后最早建立的省级中医院之一的医院，奠定了深厚的学术根基。";
        $top_bar_bg = "http://topsydy.oss-cn-hangzhou.aliyuncs.com/app/topstdy/image/doctor/doctor_top_bar_bg.png";
        echo echoJson(1, array("explain" => $explain, "top_bar_bg" => $top_bar_bg, "data" => $Info));
    }

}